package study.kits.excel.easyexcel.service.upload;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.InputStream;

@Slf4j
@Service("uploadService")
public class UploadService {

    public void upload(MultipartFile file) {
        try {
            //获取到流
            InputStream in = file.getInputStream();
            //上传指定目录下
            String fileName = file.getOriginalFilename();
            String filePath = "d:";
            File dest = new File(filePath + fileName);
            file.transferTo(dest);
        } catch (Exception ex) {
            throw new RuntimeException("", ex);
        }
    }
}
